/*
 ******************************************************************************
 *
 *       Copyright ASTRI, 2016.  All rights reserved.
 *
 *   This software is proprietary to and embodies the confidential technology
 *   of Hong Kong Applied Science and Technology Research Institute Company
 *   Limited (ASTRI).
 *   Possession, use, or copying of this software and media is authorized
 *   only pursuant to a valid written license from ASTRI or an authorized
 *   sublicensor.
 *
 * File Name:
 *   XXX.java
 *
 * Purpose:
 *   
 *   
 *   
 *
 * Project or Modules Name:
 *   
 *
 * Modules Contained:
 *   N/A
 *
 * Modification History:
 * Date(DDMMYY)  Version No Modified By  Description
 * ------------  ---------- -----------  -----------
 * 20160405       0.0.0.1    XXX     Created
 *
 ******************************************************************************
 */


package com.j.thetabk.thetas;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.NumberPicker;

import com.j.thetabk.R;


/**
 * Created by user on 19/4/2016.
 */
public class ThetaSNumberA extends ThetaSNumber {

    public interface NumberChangeListener {
        void onValueChanged();
    }
    public NumberChangeListener mListener=null;

    public void PopList(Context ctx, int index)
    {
        View dialoglayout= LayoutInflater.from(ctx).inflate(R.layout.numlayout, null);

        final NumberPicker aNumberPicker = (NumberPicker)dialoglayout.findViewById(R.id.numberPicker);
        aNumberPicker.setMaxValue(maxValue);
        aNumberPicker.setMinValue(minValue);
        aNumberPicker.setValue(value);

        AlertDialog.Builder builder = new AlertDialog.Builder(ctx, AlertDialog.THEME_HOLO_DARK);
        builder.setTitle(numberName[index]);
        builder.setView(dialoglayout);
        builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog,
                                int id) {
                int newv = aNumberPicker.getValue();
                if (newv != value) {
                    value = newv;
                    if (mListener!=null)
                        mListener.onValueChanged();
                }
            }
        });
        builder.show();
    }

}
